$(function(){

    var str = decodeURI(location.search);
    var str = str.slice(1);
    arr = str.split("&");
    str = arr[0];
    arr = str.split("=");
    var id = +arr[1];

    var str2 = decodeURI(location.search);
    str2 = str2.slice(1);
    var arr2 = str2.split("&");
    str2 = arr2[1];
    arr2 = str2.split("=");
    var tv = arr2[1];



    // 渲染商品详情页
    $.ajax({
        url: "http://127.0.0.1:9090/api/getproduct",
        data: { productid: id},
        dataType: "json",
        success: function(result){
            console.log(result);
            nav = result.result[0].productName.split(" ")[0];
            result.result[0].nav=nav;
            result.result[0].tv = tv;
            $(".mm-top").html(template("temp-title",result));
        }
    });

    $.ajax({
        url: "http://127.0.0.1:9090/api/getproductcom",
        data: { productid: id},
        dataType: "json",
        success: function(result){
            console.log(result);
            $(".mm-foot").html(template("temp-text",result));
        }
    });

    $(".mm-top").on("click",".cate-nav a:nth-child(2)",function(){
        history.back();
    });

});